﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace OrderSample
{
    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)]
    public class TraceFilterAttribute : ActionFilterAttribute
    {
        public string Message { get; set; }

        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            filterContext.HttpContext.Trace.Write(
                "Trace Filter",
                String.Format("TraceFilter.OnActionExecuting: Order {0}, {1}",
                Order, Message)
                );
        }

        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            filterContext.HttpContext.Trace.Write(
                "Trace Filter",
                String.Format("TraceFilter.OnActionExecuted: Order {0}, {1}",
                Order, Message)
                );
        }
    }
}
